'use strict';

module.exports = app => {
  const { STRING, UUID, UUIDV4, INTEGER, BIGINT } = app.Sequelize;

  const model = app.model.define('user', {
    userid: {
      type: STRING,
      primaryKey: true,
      comment: '主键',
    },
    dingId: {
      type: STRING,
      comment: '钉钉ID',
    },
    mobile: {
      type: STRING,
      comment: '手机号',
    },
    tel: {
      type: STRING,
      comment: '分机号',
    },
    workPlace: {
      type: STRING,
      comment: '办公地点',
    },
    remark: {
      type: STRING,
      comment: '备注',
    },
    order: {
      type: BIGINT,
      comment: '表示人员在此部门中的排序，列表是按order的倒序排列输出的，即从大到小排列输出的',
    },
    isAdmin: {
      type: INTEGER,
      comment: '是否是企业的管理员, 1是 0否',
    },
    isBoss: {
      type: INTEGER,
      comment: '是否为企业的老板, 1是, 0否',
    },
    isHide: {
      type: INTEGER,
      comment: '是否隐藏号码，1是，0否',
    },
    name: {
      type: STRING,
      comment: '成员名称',
    },
    active: {
      type: INTEGER,
      comment: '表示该用户是否激活了钉钉',
    },
    department: { // 数组
      type: STRING,
      comment: '成员所属部门id列表',
    },
    position: {
      type: STRING,
      comment: '职位信息',
    },
    email: {
      type: STRING,
      comment: '员工的邮箱',
    },
    orgEmail: {
      type: STRING,
      comment: '员工的企业邮箱',
    },
    avatar: {
      type: STRING,
      comment: '头像url',
    },
    jobnumber: {
      type: STRING,
      comment: '员工工号',
    },
    role_id: {
      type: INTEGER,
      comment: '角色',
    },
    password: {
      type: STRING,
      comment: '密码',
      defaultValue: '1',
    },
  }, {
    tableName: 'user',
    comment: '用户表',
  });

  return model;
};
